package com.clutch.student.Fragment;

/**
 * Created by asus on 2018/3/17.
 * BottomNavigationView对应的第三个Fragment
 * 显示个人信息
 * 从修改信息的界面返回ThirdFragment时，状态为onResume,重写onResume方法实现刷新数据。
 */

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.clutch.student.Dao.StudentDao;
import com.clutch.student.EditCheck;
import com.clutch.student.Entity.Student_info;
import com.clutch.student.LoginActivity;
import com.clutch.student.MainActivity;
import com.clutch.student.MyActivity;
import com.clutch.student.MyApplication;
import com.clutch.student.MySourseActivity;
import com.clutch.student.R;
import com.clutch.student.StudentChangeActivity;
import com.clutch.student.ThirdRragment2Activity;

import java.util.List;


public class ThirdFragment extends Fragment implements  View.OnClickListener{
    Context context = MyApplication.getInstance();
    private StudentDao student = new StudentDao(context);
    private List<Student_info> StudentList = student.getStudent(MainActivity.getStudentId());
    private RecyclerView recyclerView;
    private int studentId = MainActivity.getStudentId();
    private  static RelativeLayout  rl_logout;
    Button btn;
    public ThirdFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             final Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        //第三个碎片连接fragment_my
        View view = inflater.inflate(R.layout.fragment_my, container, false);
        return view;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        //控件
        RelativeLayout rl_course;
        RelativeLayout rl_skin;
        RelativeLayout re_logout;

        //控件ID
        rl_course = (RelativeLayout) getActivity().findViewById(R.id.rl_course);
        rl_skin = (RelativeLayout) getActivity().findViewById(R.id.rl_skin);
        re_logout = (RelativeLayout) getActivity().findViewById(R.id.rl_logout);

        //我的课程
        rl_course.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(), MySourseActivity.class);
                startActivity(intent);
            }
        });

        //个人信息
        rl_skin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(), ThirdRragment2Activity.class);
                startActivity(intent);

            }
        });
        //退出登录
        re_logout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(), LoginActivity.class);
                startActivity(intent);
                getActivity().finish();
            }
        });



    }


    @Override
    public void onClick(View view) {

    }
}